package com.example.tcp.client.store.impl;

import com.example.tcp.client.store.AbstractDequeStore;

import java.util.LinkedList;

public class MemoryDequeStore<T>  extends AbstractDequeStore<T> {

    private LinkedList<T> elements = new LinkedList<T>();

    @Override
    public boolean isEmpty() {
        return elements.isEmpty();
    }

    @Override
    public Object wrap() {
        return elements;
    }

    @Override
    protected boolean _enqueue(T e) {
        elements.addLast(e);
        return true;
    }

    @Override
    protected T _dequeue() {
        return elements.removeFirst();
    }

    @Override
    protected void _close() {

    }

    @Override
    public T peek() {
        return elements.peek();
    }

    @Override
    public long size() {
        return elements.size();
    }
}
